package cn.njxzc.ppt;

import java.text.SimpleDateFormat;
import java.util.Date;

class MobilePhone {
	private String type;
	private Watch w;

	MobilePhone(String s) {
		type = s;
	}

	void setWatch(Watch a) {
		w = a;
	}

	long getTime() {
		return w.getTime();
	}
}

/**
 * *
 * 
 * @Program Name : JavaProgram.ppt.Jex6_12.java
 * @Written by : Roy Xu
 * @Creation Date : 2016��4��5�� ����9:03:17
 * @version : v1.00
 * @Description : public static long currentTimeMillis()the difference, measured
 *              in milliseconds, between the current time and midnight, January
 *              1, 1970 UTC
 * @ModificationHistory Who When What -------- ----------
 *                      ------------------------------------------------ Roy Xu
 *                      2016��4��5������9:03:17 TODO
 ** 
 */
class Watch {
	long getTime() {
		return System.currentTimeMillis();
	}

	public String refFormatNowDate() {
		Date nowTime = new Date(System.currentTimeMillis());
		SimpleDateFormat sdFormatter = new SimpleDateFormat("yyyy-MM-dd");
		String retStrFormatNowDate = sdFormatter.format(nowTime);
		return retStrFormatNowDate;
	}
}

public class Jex6_12 {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		MobilePhone mp = new MobilePhone("nokia");
		Watch w = new Watch();
		mp.setWatch(w);
		long l = mp.getTime();
		System.out.println(l);
		Date nowTime = new Date(l);
		SimpleDateFormat sdFormatter = new SimpleDateFormat("yyyy-MM-dd");
		String retStrFormatNowDate = sdFormatter.format(nowTime);
		System.out.println(retStrFormatNowDate);

	}

}
